/* uses Aitken's algorithm to compute one coordinate value of a Lagrange curve. Has to be called for each coordinate (x,y, and/or z) of data set. Input: degree: degree of curve. coeff: array with coordinates to be interpolated. t: parameter value where to interpolate. Output: coordinate value. Note: we assume a uniform knot sequence! */ float aitken(degree,coeff,t) float coeff[]; float t; int degree; { int r,i; float t1; float coeffa[30]; for (i=0; i<=degree; i++) coeffa[i]=coeff[i]; /* save input */ for (r=1; r<= degree; r++) for (i=0; i<= degree - r; i++) { t1=(degree*t-i)/((float) r); coeffa[i]= (1.0-t1)* coeffa[i] + t1 * coeffa[i+1] ; } return (coeffa[0]); } main() { float t=0.5; int degree=3; float coordx[ ]={0, 0, 0, 1}; printf("Coordinata x= %6.4 f\n ", aitken(degree, coordx, t) ); float coordy[ ]={0, 1, 0, 0}; printf("Coordinata y= %6.4 f\n ", aitken(degree, coordy,t) ); float coordz[ ]={0, 0, 1, 0}; printf("Coordinata z= %6.4 f\n ", aitken(degree, coordz,t) ); }